package cn.itcast.oa.domain;

import java.util.List;

/**
 * Created by ChengGM on 2016/12/24.
 */
public class PageBean {
    private int currentPage;
    private int pageSize;
    private int recordCount;
    private List recordList;
    private int pageCount;
    private int beginPageIndex;
    private int endPageIndex;
    public PageBean(int currentPage,int pageSize,int recordCount,List recordList){
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.recordCount = recordCount;
        this.recordList = recordList;
        //计算总页码
        pageCount = (recordCount +pageSize-1)/pageSize;
        if(pageCount<=10){
            beginPageIndex = 1;
            endPageIndex = pageCount;
        }else {
            beginPageIndex = currentPage =4;
            endPageIndex =currentPage + 5;
            if(beginPageIndex<1){
                beginPageIndex =1;
                endPageIndex= 10;
            }
            if(endPageIndex>pageCount){
                endPageIndex = pageCount;
                beginPageIndex = pageCount - 10 + 1;
            }
        }

    }

    public List getRecordList() {
        return recordList;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getRecordCount() {
        return recordCount;
    }

    public void setRecordCount(int recordCount) {
        this.recordCount = recordCount;
    }

    public void setRecordList(List recordList) {
        this.recordList = recordList;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getBeginPageIndex() {
        return beginPageIndex;
    }

    public void setBeginPageIndex(int beginPageIndex) {
        this.beginPageIndex = beginPageIndex;
    }

    public int getEndPageIndex() {
        return endPageIndex;
    }

    public void setEndPageIndex(int endPageIndex) {
        this.endPageIndex = endPageIndex;
    }
}
